package cn.zhx.xa.system.controller;


import cn.zhx.xa.model.dto.role_menu.AssignMenuDto;
import cn.zhx.xa.model.vo.common.Result;
import cn.zhx.xa.model.vo.common.ResultCodeEnum;
import cn.zhx.xa.system.service.SysRoleMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping(value = "/api/system/sysRoleMenu")
@Tag(name = "角色菜单关系管理")
public class SysRoleMenuController {

    @Resource
    private SysRoleMenuService sysRoleMenuService ;

    @GetMapping(value = "/auth/findSysRoleMenuByRoleId/{roleId}")
    @Operation(summary = "根据角色id查询菜单")
    public Result<Map<String , Object>> findSysRoleMenuByRoleId(@PathVariable(value = "roleId") Long roleId) {
        Map<String , Object> sysRoleMenuList = sysRoleMenuService.findSysRoleMenuByRoleId(roleId) ;
        return Result.build(sysRoleMenuList , ResultCodeEnum.SUCCESS) ;
    }

    @PostMapping("/auth/doAssign")
    @Operation(summary = "分配菜单")
    public Result doAssign(@RequestBody AssignMenuDto assignMenuDto) {
        sysRoleMenuService.doAssign(assignMenuDto);
        return Result.build(null , ResultCodeEnum.SUCCESS) ;
    }

}